﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ZenSystemService.Api.Migrations
{
    /// <inheritdoc />
    public partial class ProductLabeled : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ProductReleases");

            migrationBuilder.DropIndex(
                name: "IX_CourseTrainees_TraineeInfoUserId",
                table: "CourseTrainees");

            migrationBuilder.DropColumn(
                name: "TraineeInfoUserId",
                table: "CourseTrainees");

            migrationBuilder.CreateTable(
                name: "ProductLabeleds",
                columns: table => new
                {
                    ProductLabeledId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    ProductId = table.Column<int>(type: "int", nullable: false),
                    Status = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductLabeleds", x => x.ProductLabeledId);
                    table.ForeignKey(
                        name: "FK_ProductLabeleds_Products_ProductId",
                        column: x => x.ProductId,
                        principalTable: "Products",
                        principalColumn: "ProductId",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_ProductLabeleds_ProductId",
                table: "ProductLabeleds",
                column: "ProductId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ProductLabeleds");

            migrationBuilder.AddColumn<int>(
                name: "TraineeInfoUserId",
                table: "CourseTrainees",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.CreateTable(
                name: "ProductReleases",
                columns: table => new
                {
                    ProductReleaseId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    ProductId = table.Column<int>(type: "int", nullable: false),
                    Status = table.Column<string>(type: "longtext", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ProductReleases", x => x.ProductReleaseId);
                    table.ForeignKey(
                        name: "FK_ProductReleases_Products_ProductId",
                        column: x => x.ProductId,
                        principalTable: "Products",
                        principalColumn: "ProductId",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_CourseTrainees_TraineeInfoUserId",
                table: "CourseTrainees",
                column: "TraineeInfoUserId");

            migrationBuilder.CreateIndex(
                name: "IX_ProductReleases_ProductId",
                table: "ProductReleases",
                column: "ProductId");

        }
    }
}
